<?php namespace  App\Http\Controllers;

use App\PhoneFlowing;
use App\phoneMsg;
use Illuminate\Support\Facades\Input;

class ManagerController extends Controller
{
    public function login(){

    }

    public function mainPage(){
        return view('manager.mainpage');
    }

    public function phoneList(){

        $allPhone = phoneMsg::all();
        return view('manager.phone-list',['phones'=>$allPhone]);
    }

    public function phoneData(){
        $id = Input::get('id');

        $thatData = PhoneFlowing::wherePhoneMsgId($id)->get();
        $taday = strtotime(date('Y-m-d',time()));

        $everyData = array();
        foreach($thatData as $data){
            /** @var PhoneFlowing $data */
            $createTime = strtotime($data->created_at);
            if($createTime >= $taday && $createTime < ($taday + 3600)){
                $everyData[0] = (int)$everyData[0] + (int)$data->num;
            }elseif($createTime >= $taday+3600 && $createTime < ($taday + 7200)){
                $everyData[1] = (int)$everyData[1] + (int)$data->num;
            }
        }
    }
}